scale-color

 

scale-color is a primitive that reports a shade of a color proportional to the value of a given number. For example, in a traffic model, one might use scale-color to color cars with a full tank of gas brighter than those with an emptier tank of gas, or, in a model of a flock of sheep, color more lush patches of grass brighter than those that have already been eaten plenty.

In practice, you use scale-color like so: scale-color color number range1 range2, where color is the desired base hue (red, blue, green, etc.), number is the value you wish to scale by (often a turtle or patch variable), and range1 and range2 are parameters for describing the minimum and maximum expected values of number. If range1 is less than range2, then larger numbers result in brighter colors, but if range2 is less than range, then larger numbers result in darker colors. If the number is outside of the range, then either the lightest or darkest shade is chosen.

In this model, scale-color is used to model cell-tower signal strength. Patches closer to the cell towers have better signal strength and are therefore colored brighter than those too far away from a tower to get any signal.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the scale-color primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Similar primitives:
color

built-in turtle characteristic that changes the color of the turtle

Read more
pcolor

built-in patch variable that holds the color of the patch

Read more
set

Set the value of a variable.

Read more
turtles-own

Declare a variable that belongs to turtles.

Read more
 
Learn another primitive